<?php
    if(!defined('MVMMALL')){
        exit('Access Denied');
    }
    /* 配送方式插件的代码必须和文件名保持一致 */
    $shipping['ems']['name']    = 'EMS国内邮政特快专递';
    
    /* 配送方式的描述 */
    $shipping['ems']['desc']    = 'EMS 国内邮政特快专递';
    
    /* 不支持保价 */
    $shipping['ems']['insure']  = 0;
    
    /* 配送方式是否支持货到付款 */
    $shipping['ems']['cod']     = 0;
    
     /* 版权信息*/
    $shipping['ems']['license']  = '版权所有www.mvmmall.com';

    /* 配送接口需要的参数 */
    $shipping['ems']['cfg'] = array(
                                    array('name' => 'base_fee', 'value'=>20,'label'=>'500克以内费用'),
                                    array('name' => 'step_fee', 'value'=>15,'label'=>'续重每500克或其零数'),
                                );

class ems
{
    var $cfg;
    
    /*配置信息*/
    function ems($cfg = array())
    {
         foreach ($cfg AS $key=>$val)
        {
            $this->cfg[$val['name']] = $val['value'];
        }
    }
    /*计算费用*/
    function exes($kg,$price)
    {
        if ($this->cfg['free_money'] > 0 && $price >= $this->cfg['free_money'])
        {
            return 0;
        }
        else
        {
            $fee = $this->cfg['base_fee'];
            if ($kg > 0.5)
            {
                $fee += (ceil(($kg - 0.5) / 0.5)) * $this->cfg['step_fee'];
            }
            return $fee;
        }
    }

    /*询问定单*/
    function demand($sn)
    {
         $str = '<form style="margin:0px" method="post" '.
            'action="http://www.ems.com.cn/qcgzOutQueryAction.do" name="queryForm_' .$sn. '" target="_blank">'.
            '<input type="hidden" name="mailNum" value="' .$sn. '" />'.
            '<a href="javascript:document.forms[\'queryForm_' .$sn. '\'].submit();">' .$sn. '</a>'.
            '<input type="hidden" name="reqCode" value="browseBASE" />'.
            '<input type="hidden" name="checknum" value="0568792906411" />'.
            '</form>';

        return $str;
    }
}